package main

import (
	"encoding/json"
	"fmt"
)

type Gender string

const (
	Female Gender = "female"
	Male   Gender = "male"
)

type User struct {
	Gender Gender `json:"gender"`
	Name   string `json:"name"`
}

func main() {
	user := User{
		Gender: Female,
		Name:   "jack",
	}

	value, _ := json.Marshal(user)

	fmt.Println(string(value))

	user2 := &User{}
	_ = json.Unmarshal(value, user2)
	fmt.Printf("%+v", user2)
}
